
exports.view = function(app){
	app.use(function(req, res, next){
		if (!req.session.user) {
			if(req.url=="/login"){
				next();//如果请求的地址是登录则通过，进行下一个请求
			}
			else
			{
				res.redirect('/login');
			}
		} else if (req.session.user) {
			next();
		}
	});

	// [VIEW]
	home(app);

	// [REST]
	sale(app);
}

function home(app) {

	// { routes } { View }
 	
 	var routes = require('./home');

	// Home Login
	app.get('/login', routes.Login);

	// Home LoginAth
	app.post('/login', routes.LoginAth);

	// Home Index
	app.get('/', routes.Index);

	// Home Editormd
	app.get('/home/editormd', routes.Editormd);

	// Save Editormd
	// Request Type: post
	// Url: /home/saveeditormd
	app.post('/home/saveeditormd', routes.SaveEditormd);

	// Home FreightTiered
	//var 
	app.get('/home/FreightTiered', routes.FreightTiered);

}

function sale(app){

	var routes = require('./sale');

	// Sale Orders
	app.get('/sale', routes.Index);


	// Get Order List
	// Request Type: get
	// Url: /sale/order	
	app.get('/sale/order', routes.GetOrders);

}